<?php

############################################
##          Code by Vu Quang Tam          ##
##       Email: quangtam.info@gmail.com   ##
##       Website: http://quangtam.info    ##
##                http://wapmaster.vn     ##
##     SDT: 0916 097 381 - 0982 655 098   ##
##             May 24, 2011               ##
############################################

class SpeedSMSConfig {

    public static $DB_HOST = "localhost";
    public static $DB_USER = "root";
    public static $DB_PASS = "123456";
    public static $DB_NAME = "speedsms";
    public static $TB_FIX = "sp_";
    public static $TIME_GAME = 160;

}

class mysql {

    var $link_id;
    var $log_file = 'logs.txt';
    var $log_error = 1;

    function connec() {
        $connection = mysql_connect(SpeedSMSConfig::$DB_HOST, SpeedSMSConfig::$DB_USER, SpeedSMSConfig::$DB_PASS);
        $select = mysql_select_db(SpeedSMSConfig::$DB_NAME, $connection);
    }

    function query($input) {
        $q = @mysql_query($input) or $this->show_error("<b>Error MySQL Query</b> : " . mysql_error(), $input);
        return $q;
    }

    function fetch_array($query_id, $type=MYSQL_BOTH) {
        $fa = @mysql_fetch_array($query_id, $type);
        return $fa;
    }

    function num_rows($query_id) {
        $nr = @mysql_num_rows($query_id);
        return $nr;
    }

    function result($query_id, $row=0, $field) {
        $r = @mysql_result($query_id, $row, $field);
        return $r;
    }

    function insert_id() {
        return @mysql_insert_id($this->link_id);
    }

    function show_error($input, $q) {
        if ($this->log_error) {
            $file_name = $this->log_file;
            $fp = fopen($file_name, 'a');
            flock($fp, 2);
            fwrite($fp, "### " . date('H:s:i d-m-Y', NOW) . " ###\n");
            fwrite($fp, $input . "\n");
            fwrite($fp, "QUERY : " . $q . "\n");
            flock($fp, 1);
            fclose($fp);
        }
        die($input);
    }

    public function disconnect() {
        if (is_resource($this->connection)) {
            mysql_close($this->connection);
        }
    }

}
?>